//
//  GuideTitleView.m
//  JiaoX
//
//  Created by yinqy on 15/1/26.
//  Copyright (c) 2015年 北京娇羞科技有限公司. All rights reserved.
//

#import "GuideTitleView.h"

#define TITLE_FONT_SIZE [DimensUtils getScaleY:22]
#define SUBTITLE_FONT_SIZE [DimensUtils getScaleY:15]

@interface GuideTitleView(){
    
    UILabel *_titleLabel;
    UILabel *_subTitleLabel;
}

@end
@implementation GuideTitleView

-(instancetype)initWithTitle:(NSString *)title subTitle:(NSString *)subTitle{
    self = [super init];
    if (self) {
        //添加title
        _titleLabel = [[UILabel alloc]init];
        [_titleLabel setFont:[UIFont systemFontOfSize:TITLE_FONT_SIZE]];
        [_titleLabel setTextColor:JXColor(77, 77, 77)];
        [_titleLabel setText:title];
        CGSize titleSize = [title sizeWithFont:_titleLabel.font];
        [_titleLabel setFrame:CGRectMake((JXScreenW-titleSize.width)/2, 0, titleSize.width, titleSize.height)];
        [self addSubview:_titleLabel];
        
        //添加subTitle
        _subTitleLabel = [[UILabel alloc]init];
        [_subTitleLabel setFont:[UIFont systemFontOfSize:SUBTITLE_FONT_SIZE]];
        [_subTitleLabel setTextColor:JXColor(128, 128, 128)];
        [_subTitleLabel setText:subTitle];
        [_subTitleLabel setNumberOfLines:0];
        [_subTitleLabel setTextAlignment:NSTextAlignmentCenter];
        CGSize subTitleSize = [subTitle sizeWithFont:_subTitleLabel.font constrainedToSize:CGSizeMake(MAXFLOAT, MAXFLOAT)];
        [_subTitleLabel setFrame:CGRectMake((JXScreenW-subTitleSize.width)/2, CGRectGetMaxY(_titleLabel.frame)+[DimensUtils getScaleY:JXPublicInset], subTitleSize.width, subTitleSize.height)];
        [self addSubview:_subTitleLabel];
        
        [self setSize:CGSizeMake(JXScreenW, CGRectGetMaxY(_subTitleLabel.frame))];
    }
    return self;
}


@end
